package com.grt.condify.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@EqualsAndHashCode(callSuper = false)
@Data
@Table(name = "Person")
@TableName(value = "Person")
@TableEngine(value = MySqlEngineConstant.InnoDB)
public class Person {
    /**
     * 主键
     */
    @IsKey
    @IsAutoIncrement
    @TableId(type = IdType.AUTO)
    @Column(value = "person_id")
    Integer personId;

    @Column(value = "name")
    String name;

    @Column(value = "nick_name")
    String nickName;


    @Column(value = "age")
    Integer age;

    @Column(value = "json_schema",type = MySqlTypeConstant.JSON)
    @TableField(typeHandler = FastjsonTypeHandler.class)
    Object jsonSchema;

    /**
     * 创建时间
     */
    @Column(value = "cr_time", type = MySqlTypeConstant.DATETIME)
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    Date crTime;

    @Override
    public String toString(){
        return this.name;
    }
}
